<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

// 自动加载类
require_once __DIR__ . '/vendor/autoload.php';
$map = new tool\Map(10000, 10000);
# 先测试 tile
$string1 ='';
$start = microtime(true)*1000;
for($i=0;$i<100000000;$i++){
    $pos = $map->getRandom();
    $xystring= $map->GridPositionToTileIndex($pos[0], $pos[1]);
    $pos19 =$map->decode($xystring);
    
//    $string1.= $xystring;
//    var_dump($xystring,$pos19,$pos);
}
//var_dump(strlen($string1));
var_dump( microtime(true)*1000-$start);
// 1000*1000 节省15% 的长度
// 10000*10000 节省11% 的长度
// 100000*100000 节省9% 的长度

# 测试 string储存
$string1 ='';
$start = microtime(true)*1000;
for($i=0;$i<100000000;$i++){
    $pos = $map->getRandom();
    $xystring = tool\Map::xyToString($pos[0], $pos[1]);
    $pos19 = tool\Map::stringToXy($xystring);
//    $string1.= $xystring;

}
//var_dump(strlen($string1));
var_dump( microtime(true)*1000-$start);


// 速度对比 tile 比 string 几近相等


